home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / reve / trans / trans.ps < prev   
Encoding:
Text File  |  1995-05-03  |  5.7 KB  |  201 lines

  1.  
  2. %  @(#)trans.ps 1.1 91/02/18
  3. %
  4. %  Copyright (C) 1991 - Valerie Haecky.
  5. %  All rights reserved.
  6. %
  7. %  Permission is granted to copy this source, for redistribution 
  8. %  in source form only, provided the news headers in "substantially 
  9. %  unaltered format" are retained, the introductory messages are not 
  10. %  removed, and no monies are exchanged. 
  11. %
  12. %  Permission is also granted to copy this source, without the 
  13. %  news headers, for the purposes of making an executable copy by 
  14. %  means of compilation, provided that such copy will not be used 
  15. %  for the purposes of competition in any othello tournaments, without 
  16. %  prior permission from the authors. 
  17. %
  18. %  No responsibility is taken for any errors on inaccuracies inherent 
  19. %  either to the comments or the code of this program, but if reported 
  20. %  (see README file), then an attempt will be made to fix them. 
  21.  
  22. /BoardBottom 150 def
  23. /BoardLeft   200 def
  24. /BoardWidth  816 def % divisible by 8 and 3 and 102
  25. /TopMargin   BoardBottom BoardWidth 450 add add def
  26. /SquareWidth BoardWidth 8 idiv def
  27. /Title       (Reve Transcript) def
  28. /TextGap     50 def
  29. /ScaleFactor {0.5 0.5} def
  30. /Gap SquareWidth 3 idiv def
  31. /UpX BoardLeft Gap sub def
  32. /OverY BoardBottom BoardWidth Gap add add def
  33.  
  34. /drawBoard { % - => -
  35.     newpath
  36.       2 setlinewidth
  37.       BoardLeft BoardBottom moveto
  38.       4 {
  39.         BoardWidth  0 rlineto
  40.         0 SquareWidth rlineto
  41.         BoardWidth neg 0 rlineto
  42.         0 SquareWidth rlineto 
  43.       } repeat
  44.       BoardWidth  0 rlineto  
  45.       4 {
  46.         0 BoardWidth neg  rlineto
  47.         SquareWidth neg 0 rlineto  
  48.         0 BoardWidth      rlineto
  49.         SquareWidth neg 0 rlineto
  50.       } repeat
  51.       0 BoardWidth neg  rlineto 
  52.     stroke
  53. } def
  54.  
  55. /labelBoard { % - => -
  56.   newpath
  57.     0 setgray
  58.     /Helvetica-Bold findfont 30 scalefont setfont
  59.  
  60.     UpX BoardBottom Gap add moveto (8) show
  61.     UpX BoardBottom Gap SquareWidth add add  moveto (7) show
  62.     UpX BoardBottom Gap SquareWidth 2 mul add add  moveto (6) show
  63.     UpX BoardBottom Gap SquareWidth 3 mul add add  moveto (5) show 
  64.     UpX BoardBottom Gap SquareWidth 4 mul add add  moveto (4) show 
  65.     UpX BoardBottom Gap SquareWidth 5 mul add add  moveto (3) show 
  66.     UpX BoardBottom Gap SquareWidth 6 mul add add  moveto (2) show 
  67.     UpX BoardBottom Gap SquareWidth 7 mul add add  moveto (1) show 
  68.  
  69.     BoardLeft Gap add OverY moveto (a) show
  70.     BoardLeft Gap SquareWidth add add  OverY moveto (b) show
  71.     BoardLeft Gap SquareWidth 2 mul add add OverY  moveto (c) show
  72.     BoardLeft Gap SquareWidth 3 mul add add OverY  moveto (d) show
  73.     BoardLeft Gap SquareWidth 4 mul add add OverY  moveto (e) show
  74.     BoardLeft Gap SquareWidth 5 mul add add OverY  moveto (f) show
  75.     BoardLeft Gap SquareWidth 6 mul add add OverY  moveto (g) show
  76.     BoardLeft Gap SquareWidth 7 mul add add OverY  moveto (h) show
  77. } def
  78.  
  79. /drawStar { % mul1 mul2 => -
  80.   newpath
  81.     0 setgray 
  82.     BoardLeft SquareWidth 4 -1 roll mul add % mul2 x
  83.     exch
  84.     BoardBottom SquareWidth 3 -1 roll mul add % y
  85.     SquareWidth 90 sub 2 idiv 0 360 arc fill
  86. } def
  87.  
  88. /drawStars { % - => -
  89.   newpath
  90.     2 6 drawStar 
  91.     2 2 drawStar 
  92.     6 2 drawStar 
  93.     6 6 drawStar
  94. } def
  95.  
  96. /showTitle { % - => -
  97.   newpath
  98.     /Helvetica-Bold findfont 
  99.     40 scalefont
  100.     setfont
  101.     BoardLeft Gap sub TopMargin moveto
  102.     Title show
  103.  
  104.     % Now for the other fields:
  105.     /Helvetica findfont
  106.     30 scalefont setfont
  107.  
  108.     BoardLeft TopMargin TextGap 1 mul sub moveto
  109.     (Black: ) show
  110.     BlackPlayer show
  111.  
  112.     BoardLeft TopMargin TextGap 2 mul sub moveto
  113.     (White: ) show
  114.     WhitePlayer show
  115.  
  116.     BoardLeft TopMargin TextGap 3 mul sub moveto
  117.     (Score: ) show
  118.     Score show
  119.  
  120.     BoardLeft TopMargin TextGap 4 mul sub moveto 
  121.     (Date: ) show
  122.     Date show
  123.  
  124.     BoardLeft TopMargin TextGap 5 mul sub moveto
  125.     (Place: ) show
  126.     Place show 
  127.  
  128.     BoardLeft TopMargin TextGap 6 mul sub moveto
  129.     (Time Limit: ) show
  130.     Time show 
  131.  
  132.     BoardLeft TopMargin TextGap 7 mul sub moveto
  133.     (Comments: ) show
  134.     Comments show 
  135. } def
  136.  
  137. /drawStone { % number square color => x y
  138.   newpath
  139.     2 setlinewidth
  140.     
  141.     % a little gray looks better on the printer and does not disturb screen
  142.     dup 0 eq {pop 0.05} if
  143.     dup setgray exch        % number color square
  144.  
  145.     % The next line is a fix to change orientation. Did this instead
  146.     % of rewrite, because we might want to do something with orientation
  147.     % later. Then this line would become a function, and we would have
  148.     % an additional orientation option in the c part.
  149.     % 23 -> 32
  150.     dup 10 mod 10 mul exch 10 idiv add
  151.  
  152.     dup             % number color square square (use 23 as example)
  153.     10 mod             % number color square 3
  154.     1 sub             % number color square 2
  155.     SquareWidth mul         % number color square 204
  156.     SquareWidth 2 idiv add     % number color square 255
  157.     BoardLeft add         % number color square x
  158.     exch            % number color x square
  159.  
  160.     10 idiv             % number color x 2
  161.     9 sub neg 1 sub             % number color x 6
  162.     SquareWidth mul        % number color x 612
  163.     SquareWidth 2 idiv add
  164.     BoardBottom add        % number color x y
  165.  
  166.     % draw the circle 
  167.     1 index 1 index        % number color x y x y
  168.     SquareWidth 20 sub 2 idiv 0 360 arc fill % number color x y
  169.     1 index 1 index        % number color x y x y
  170.     0 setgray
  171.     SquareWidth 20 sub 2 idiv 0 360 arc stroke
  172.     3 index 0 ne {drawNumber} if    % only draw number if no 0
  173. } def
  174.  
  175. /drawNumber { % number color x y => -
  176.   newpath
  177.     3 index 9 gt
  178.       {13 sub exch 15 sub exch}        % ad hoc correction for centering
  179.       {12 sub exch 9 sub exch} ifelse
  180.     moveto            % number color
  181.     /Helvetica-Bold findfont 
  182.     30 scalefont setfont
  183.     1 eq {0 setgray} {1 setgray} ifelse
  184.     2 string cvs show 
  185. } def
  186.  
  187. gsave
  188.   ScaleFactor scale
  189.   Scale scale
  190.   showTitle
  191.   drawBoard
  192.   labelBoard
  193.   drawStars
  194.   
  195. % initial stones
  196.   0 44 1 drawStone
  197.   0 45 0 drawStone
  198.   0 54 0 drawStone
  199.   0 55 1 drawStone
  200.